package com.hongyuan.venue.ui.home.view_mode;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
import com.hongyuan.mvvmhabitx.binding.command.BindingAction;
import com.hongyuan.mvvmhabitx.binding.command.BindingCommand;
import com.hongyuan.venue.base.ItemViewModel;
import com.hongyuan.venue.data.Constants;
import com.hongyuan.venue.ui.home.beans.Venue;

public class HomeCouponItemViewModel extends ItemViewModel<FragmentHomeViewModel> {

    public ObservableField<Venue.CouponListBean> entity = new ObservableField<>();
    public int position;
    public int maxPosition;

    public HomeCouponItemViewModel(@NonNull FragmentHomeViewModel viewModel, Venue.CouponListBean bean,int i,int maxPosition) {
        super(viewModel);
        entity.set(bean);
        position = i;
        this.maxPosition = maxPosition;
    }

    //条目的点击事件
    public BindingCommand lingque = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            viewModel.itemClick(HomeCouponItemViewModel.this);
            viewModel.setParams("coupon_id",String.valueOf(entity.get().getCoupon_id()));
            viewModel.requestData(Constants.GET_COUPON);
        }
    });
}
